package org.example;
import java.sql.*;

public class viewAllDate {

    public static void viewAllRecords(String url,String user,String password) {
        try {
            // SQL语句：查询所有记录
            String sql = "SELECT * FROM first_table";
            // 获取连接
            Connection conn = DriverManager.getConnection(url, user, password);
            // 创建Statement对象
            Statement stmt = conn.createStatement();
            // 执行查询操作
            ResultSet rs = stmt.executeQuery(sql);
            while (rs.next()) {
                int id = rs.getInt("Id");
                String itemName = rs.getString("item_name");
                String value = rs.getString("Value");
                System.out.println("ID: " + id + ", Item Name: " + itemName + ", Value: " + value);
            }

            // 关闭资源
            rs.close();
            stmt.close();
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
